Answer:

The program will print:

Hours per Week      12
Hours per Semester  180
Ho Hum...

Names for Variables

Remember that a variable is a small amount of computer memory that has been given a name. So far you have seen several names for variables:

NUM                POUNDS
VALUE              MILE
SUM                CLASSES
AGE

Names for variables are single words that the programmer picks. The names don't have to be real words, but it helps in understanding the program if they are. Look over the following rules. (Just read through them once or twice; you don't have to memorize them.)

Rules for Variable Names

  1. A variable is a small amount of computer memory that has been given a name.
  2. The name is:
    • up to 40 characters long,
    • the first character must be A-Z, a-z,
    • the rest of the characters must be A-Z, a-z, 0-9, or "."
    • no spaces are allowed inside of a name.
  3. You can't use a word that is already used for something else. (You can't use PRINT as a name vor a variable.)
  4. The last character of the name tells what type of data the memory holds:
    • SUM%       holds an integer (no decimal point)
    • SUM&       holds a potentially very big integer
    • SUM         holds a floating point number (can have a decimal point)
    • SUM#       holds a potentially very big floating point number
    • SUM$       holds a string of characters
  5. Different names mean different places in memory.
  6. The last character is part of the name, (so SUM% and SUM are different variables.)
  7. If two names differ only in upper and lower case characters, they are really the same name.

So far we have been using variables that hold floating point numbers (those with a possible decimal point like the numbers on a hand calculator.) This type of variable is the most useful. These variables can hold numbers like 1.3, -45.78, 0.001, and can also hold numbers without a fractional part like 1.0, -23.0, 94.0 and others.

QUESTION 8:

Which of the following are OK names to use for a variable that will hold a floating point number?

SUM             GRAND TOTAL
MyValue         16Candles
SUM23           YEAR%